package finalproject.model.items;

import finalproject.model.player.Player;
import finalproject.view.StringManager;

/**
 * This class is the oopBook class, representing a book that gives the player acces to every lecture
 * It uses the singleton pattern, for there can be only one OOPBook
 * 
 * @author Nicolas Bighetti
 *
 */
public class OopBook extends Item{

	/**
	 * the instance of the class
	 */
	private static OopBook INSTANCE = new OopBook();
	
	/**
	 * The main constructor of the class
	 * It is private to allow only one OOPbook instance at a given time
	 * To get the instance, one should use the method getInstance
	 */
	private OopBook()
	{
		super(StringManager.getString("oopbook"), StringManager.getString("oopbookdescription"), 10, true, false, false);
	}
	
	/**
	 * @return the instance of the class
	 */
	public static OopBook getInstance()
	{
		return INSTANCE;
	}
	
	@Override
	public void use(Player p) {
	    if(p.getEnergy().getEnergy() != 0)
	    {
	    p.getEnergy().setEnergy(p.getEnergy().getEnergy()-1);
		StringManager.outPut("readOOP");
	    }
		else
		{
		    StringManager.outPutText(StringManager.getString("exhausted")); 
		}
	}

}
